package map;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class L1 {
    //hash表
    public int[] twoSum(int[] nums, int target) {
        int[] res = new int[2];
        if(nums == null || nums.length == 0){
            return res;
        }
        Map<Integer, Integer> map = new HashMap<>();
        for (int i=0;i< nums.length;i++){
            int temp=target-nums[i];
            if (map.containsKey(temp)){
                res[1]=i;
                res[0]=map.get(temp);
                break;
            }
            map.put(nums[i],i);
        }
        return res;


    }

    public static void main(String[] args) {
        int nums[]={2,7,11,15};
        int target=9;
        L1 l1 = new L1();
        int[] ints = l1.twoSum(nums, target);
        System.out.println(1111);
    }
}
